class {
  onCreate() {
    this.state = {
      running: false,
      elapsedTime: 0
    };

    this.intervalId = null;
  }

  onDestroy() {
    if (this.state.running) {
      clearInterval(this.intervalId);
    }
  }

  handleStartClick() {
    this.state.running = true;

    this.intervalId = setInterval(() => {
      this.state.elapsedTime += 0.1;
    }, 100);
  }

  handlePauseClick() {
    clearInterval(this.intervalId);

    this.state.running = false;
  }

  handleStopClick() {
    clearInterval(this.intervalId);

    this.state.running = false;
    this.state.elapsedTime = 0;
  }
}

<div>
  <p>Elapsed time: ${state.elapsedTime.toFixed(1)}s</p>
  <button
    type="button"
    disabled=(state.running === true)
    on-click("handleStartClick")>Start</button>
  <button
    type="button"
    disabled=(state.running !== true)
    on-click("handlePauseClick")>Pause</button>
  <button
    type="button"
    disabled=((state.elapsedTime === 0) && (state.running === false))
    on-click("handleStopClick")>Stop/Clear</button>
</div>
